var o = require("gameData"),
    i = require("G");
cc.Class({
    extends: cc.Component,
    properties: {
        goldNum: cc.Label,
        maxScoreLabel: cc.Label,
        inviteList: cc.Node,
        coverLayer: cc.Node,
        continueLayer: cc.Node,
        guess: cc.Node,
        layout: cc.Node,
        attendanceLayer: cc.Node,
        newRank: cc.Node,       //主域视窗容器
        wxSubContextView: cc.Node
    },
    onLoad: function () {
        i.LocalStorage.init(), this.maxScoreLabel.string = i.LocalStorage.get("maxscore") || "0",
            this.goldNum.string = i.LocalStorage.get("gold") || "0";
        var t = cc.winSize;
        this.ratio = t.height / t.width, this.ratio > 2.06 && (console.log("大于 2.06"), this.layout.scale = 1.2),
            this.ratio < 1.4 && (console.log("小于 1.4"), this.guess.active = !1, this.layout.getComponent("cc.Widget").bottom = .2),
            i.Interface.showBannerAD();
    },
    onStartGame: function () {
        console.log("start game");
        // 取消继续游戏
        // var t = i.LocalStorage.get("level"),
        //     e = i.score;
        // 1 == t && 0 == e ? 
        (o.ifContinue = !1, cc.director.loadScene("game"));
        // this.continueLayer.getComponent("ContinueLayer").continue({
        //     level: t,
        //     success: function () {
        //         o.ifContinue = !0, cc.director.loadScene("game");
        //     }.bind(this),
        //     fail: function () {
        //         o.ifContinue = !1, i.LocalStorage.set("level", 1), i.LocalStorage.set("score", 0),
        //             cc.director.loadScene("game");
        //     }.bind(this)
        // }), cc.director.emit("clickSound");
    },
    showRankingList: function () {
        this.coverLayer.active = !0, //this.rankingList.active = !0, cc.director.emit("clickSound"),
            this.newRank.active = true;
            this.wxSubContextView.active = true;
            //i.Interface.openRank(), i.Interface.hideBannerAD();
            let score = i.LocalStorage.get("maxscore");//Math.round(Math.random()*10);
            wx.getOpenDataContext().postMessage({
                //messageType: this.openData.openRank,
                message: score,
                //MAIN_MENU_NUM: "x1"
            });
            console.log("send open rank");
    },
    closeRankingList: function () {
        this.coverLayer.active = !1, //this.rankingList.active = !1, cc.director.emit("clickSound"),
        // this.ratio >= 1.7 && (console.log("大于 1.7"), 
         this.newRank.active = false,
         this.wxSubContextView.active = false;
        // o.Interface.closeRank(),i.Interface.showBannerAD());
        wx.getOpenDataContext().postMessage({
            //messageType: this.openData.closeRank,
            message: "clear",
            //MAIN_MENU_NUM: "x1"
        });
    },
    showInviteList: function () {
        this.coverLayer.active = !0, this.inviteList.active = !0, cc.director.emit("clickSound");
    },
    closeInviteList: function () {
        this.coverLayer.active = !1, this.inviteList.active = !1, cc.director.emit("clickSound");
    },
    share: function () {
        cc.director.emit("clickSound"), i.Interface.share({
            type: 0
        });
    },
    invite: function () {
        cc.director.emit("click"), i.Interface.share({
            type: 0
        });
    }
})